﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using GDGeek;

public enum BattleEnemyGroupType
{
       OnlyOneType,
       MixType,
       BossType
}


public class BattleCreateManager : Singleton<BattleCreateManager>
{

    private List<Vector3> enemyPoint = new List<Vector3>();

    private BattleEnemyGroupType  grouptype;

    /// <summary>
    /// 这里是真实的enemyprefabname名字
    /// </summary>
    private List<string> enemyprefabName_list = new List<string>();


    /// <summary>
    /// 存储已经战斗过的战斗key
    /// </summary>
    private List<string> battle_key_list = new List<string>();

    private string pre_scene_name;

    private string battle_key;

    private bool battle_value;

    /// <summary>
    /// 获取已经战斗过的key列表，
    /// </summary>
    /// <returns></returns>
    public List<string> GetBattled_KeyList()
    {
        return battle_key_list;
    }

    /// <summary>
    /// 往战斗过的key里面存储数据，用来记录已经战斗过的key
    /// </summary>
    public void AddBattledKey(  string  scene_name , string  bk )
    {
        if(pre_scene_name == null)
        {
            pre_scene_name = scene_name;
            battle_key_list.Add(bk);
        }

       else if (scene_name == pre_scene_name)
        {
            battle_key_list.Add(bk);
        }

        else
        {
            //说明是 另外一个战斗场景
            battle_key_list.Clear();
            pre_scene_name = scene_name;
            battle_key_list.Add(bk);

        }

    }

    public string Get_BattleKey()
    {
        return battle_key;
    }

    public void  Set_BattleKey( string k)
    {
        battle_key = k;
    }

    public bool Get_BattleValue()
    {
        return battle_value;
    }

    public void Set_BattleValue(bool  v)
    {
        battle_value = v;
    }




    public void SetEnemyPrefabNameListByEnemyKeyList(List<string>  elist)
    {
        enemyprefabName_list.Clear();

        foreach(  string   ek   in  elist)
        {
             string  enemy_prefab_name =  EnemyKeyDic.GetEnemyPrefabNameByKey(ek);
             if(enemy_prefab_name != "")
            {
                enemyprefabName_list.Add(enemy_prefab_name);
            }
        } 
        
    }

    public List<string> GetEnemyPrefabNameList()
    {
        return enemyprefabName_list;
    }



    void SetEnemyPoint()
    {
        enemyPoint.Add(new Vector3(-3.04f, 1.59f, 0));
        enemyPoint.Add(new Vector3(-3.04f, 0.09f, 0));
        enemyPoint.Add(new Vector3(-3.04f, -1.35f, 0));

        enemyPoint.Add(new Vector3(-0.59f, 1.59f, 0));
        enemyPoint.Add(new Vector3(-0.59f, 0.09f, 0));
        enemyPoint.Add(new Vector3(-0.59f, -1.35f, 0));

    }

    // Use this for initialization
    void Start()
    {
        SetEnemyPoint();
        DontDestroyOnLoad(this);
    }
    public void TestFunc()
    {
        Debug.Log("初始化 BattleCreateManager");
    }

    public  void CreatEnemyByPrefabNameList()
    {
        if (enemyprefabName_list.Count == 0)
            return;

        int num = 0;
        foreach(  string  e_prefab_name  in enemyprefabName_list  )
        {
             GameObject  enemy_g =   ResourcesLoadHepler.LoadEnemy(e_prefab_name);
            if (enemy_g != null)
            {
                Debug.Log(enemyPoint[num]);
                //在指定点生成了  敌人 对象
                Instantiate(       enemy_g   ,     enemyPoint[num]     ,            enemy_g.transform.rotation);
                //还要生成 敌人对象按钮
                //先找到  按钮上一级 Gameobect ,
                //然后添加prefab 按钮
                //设置按钮的点击事件
                num++;
            }

        }

    }


    // Update is called once per frame
    void Update()
    {

    }
}
